const mysql= require('mysql')
const db=require('../db/db')
const connection = mysql.createConnection(db.mysqlConfig)
connection.connect((err)=>{
    if(err) throw err;
    console.log("连接成功")
})

 const result=(sql,res)=>{
    connection.query(sql,(err,result)=>{
            if(err){
                console.log(err)
            }else{
                let dataString=JSON.stringify(result);
                let data=JSON.parse(dataString);
                res.json({
                    status:'200',
                    msg:'连接成功',
                    data:data
                })
            }
        })
}

module.exports=result